//
//  OrderItemView.swift
//  JiaoZiTaxi
//
//  Created by Hu Gang on 2022/12/7.
//

import SwiftUI

struct OrderItemView: View {
    @State var order : OrderModel
    var body: some View {
        VStack(alignment: .leading) {
            
            HStack {
                Text("\("订单".localized())\(order.out_trade_no ?? "")/\("车牌".localized())\((order.chepai ?? ""))").font(.system(size: 14,weight: .bold))
                HStack{
                    Text("\(order.cashType)").font(.system(size: 12))
                }.padding(.horizontal,5)
                    .background(Color(hex: ColorConfig.separationColor)).cornerRadius(3).padding(.horizontal,5).padding(.vertical,5)
                Spacer()
                Text("\(order.statusType)").font(.system(size: 12,weight: .bold)).foregroundColor(Color.themeColor())
            }
            Divider()
            HStack {
                
                Image("car_runing_time").resizable().frame(width: 15, height: 15)
                Text(order.payTime).font(.system(size: 12))
                Text("出租车".localized()).font(.system(size: 12))
                Spacer()
                Text("\(order.lao_price ?? "")kip").font(.system(size: 14)).foregroundColor(.gray)
            }.padding(.top,5)
            createDestinationView().padding(.top,5)
        }
        .padding(.horizontal,15)
        .padding(.vertical,15)
            .cornerRadius(15)
            .foregroundColor(.black)
    }
    
    func createDestinationView() -> some View {
        HStack(){
            Image("car_runing_sign")
                .resizable()
                .frame(width: 5, height: 40)
            VStack(alignment: .leading){
                Text(order.start_address ?? "上车位置".localized()).foregroundColor(.black).font(.system(size: 14))
                Spacer()
                Text(order.end_address ?? "下车位置".localized()).foregroundColor(.black).font(.system(size: 14))
                
            }.frame(height: 50)
            Spacer()
            VStack(alignment: .trailing){
                Text("\(order.china_price ?? "")\("元".localized())").foregroundColor(.gray).font(.system(size: 14))
                Spacer()
                Text("\(order.distanceKM)\("Km".localized())").foregroundColor(.gray).font(.system(size: 14))
                
            }.frame(height: 50)
        }
    }
    
 

}



//struct OrderItemView_Previews: PreviewProvider {
//    static let order = OrderItemViewModel(orderNo: "00001", carNo: "浙A12345", startTime: "2022-11-01 12:00:01", endTime: "2022-11-01 12:00:01", distance: "5.5", price: "18.90")
//    static var previews: some View {
//        OrderItemView(order: order)
//    }
//}
